const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sp_goods_attr', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      primaryKey: true,
      comment: "主键id"
    },
    goods_id: {
      type: DataTypes.MEDIUMINT.UNSIGNED,
      allowNull: false,
      comment: "商品id"
    },
    attr_id: {
      type: DataTypes.SMALLINT.UNSIGNED,
      allowNull: false,
      comment: "属性id"
    },
    attr_value: {
      type: DataTypes.TEXT,
      allowNull: false,
      comment: "商品对应属性的值"
    },
    add_price: {
      type: DataTypes.DECIMAL(8,2),
      allowNull: true,
      comment: "该属性需要额外增加的价钱"
    }
  }, {
    sequelize,
    tableName: 'sp_goods_attr',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
      {
        name: "attr_id",
        using: "BTREE",
        fields: [
          { name: "attr_id" },
        ]
      },
    ]
  });
};
